//
//  ViewController.m
//  02_Work
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#import "LoginViewController.h"
#import "CheckViewController.h"
@interface ViewController () <UITextFieldDelegate>
@property (nonatomic, strong) UIView *textFieldView;
@property (nonatomic, strong) UIView *clearView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView *backGroundImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backGroundImageView.backgroundColor = [UIColor redColor];
    UIImage *image = [UIImage imageNamed:@"welcome_2"];
    [backGroundImageView setImage:image];
    [self.view addSubview:backGroundImageView];
    
    self.clearView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.clearView.alpha = 0.8;
    [self.view addSubview:self.clearView];

    
    UIImageView *logoView = [[UIImageView alloc] initWithFrame:CGRectMake(backGroundImageView.frame.size.width / 2 - 60, 100, 120, 200)];
    UIImage *logoImage = [UIImage imageNamed:@"logo_lagou"];
    [logoView setImage:logoImage];
    [self.clearView addSubview:logoView];
    
    self.textFieldView = [[UIView alloc] initWithFrame:CGRectMake(10, 350, backGroundImageView.frame.size.width - 20, 82)];
    self.textFieldView.layer.cornerRadius = 10;
    
    [self.clearView addSubview:self.textFieldView];
    
    UITextField *idTextField = [[UITextField alloc] initWithFrame:CGRectMake(40, 0, self.textFieldView.frame.size.width - 40, 40)];
    idTextField.backgroundColor = [UIColor colorWithRed:57.0 / 255 green:55.0 / 255 blue:55.0 / 255 alpha:0.8];
    idTextField.delegate = self;
    [self.textFieldView addSubview:idTextField];
    UITextField *keyTextField = [[UITextField alloc] initWithFrame:CGRectMake(40, 42, self.textFieldView.frame.size.width - 40, 40)];
    keyTextField.backgroundColor = [UIColor colorWithRed:57.0 / 255 green:55.0 / 255 blue:55.0 / 255 alpha:0.8];
    keyTextField.delegate = self;
    [self.textFieldView addSubview:keyTextField];
    
    UIImageView *idImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    idImageView.backgroundColor = [UIColor blackColor];
    UIImage *idImage = [UIImage imageNamed:@"icon_username"];
    [idImageView setImage:idImage];
    [self.textFieldView addSubview:idImageView];
    
    UIImageView *keyImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 42, 40, 40)];
    keyImageView.backgroundColor = [UIColor blackColor];
    UIImage *keyImage = [UIImage imageNamed:@"icon_password"];
    [keyImageView setImage:keyImage];
    [self.textFieldView addSubview:keyImageView];
    // 设置弧度
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:idTextField.bounds byRoundingCorners:UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *idlayer = [CAShapeLayer layer];
    idlayer.frame = idTextField.bounds;
    idlayer.path = path.CGPath;
    idTextField.layer.mask = idlayer;
    
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRoundedRect:keyTextField.bounds byRoundingCorners:UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *keyLayer = [CAShapeLayer layer];
    keyLayer.frame = idTextField.bounds;
    keyLayer.path = path1.CGPath;
    keyTextField.layer.mask = keyLayer;
    
    UIBezierPath *path2 = [UIBezierPath bezierPathWithRoundedRect:idImageView.bounds byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *idLa = [CAShapeLayer layer];
    idLa.frame = idImageView.bounds;
    idLa.path = path2.CGPath;
    idImageView.layer.mask = idLa;
    
    UIBezierPath *path3 = [UIBezierPath bezierPathWithRoundedRect:keyImageView.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *keyLa = [CAShapeLayer layer];
    keyLa.frame = keyImageView.bounds;
    keyLa.path = path3.CGPath;
    keyImageView.layer.mask = keyLa;
    
    UIButton *logButton = [UIButton buttonWithType:UIButtonTypeSystem];
    logButton.frame = CGRectMake(10, 455, backGroundImageView.frame.size.width - 20 , 40);
    logButton.backgroundColor = [UIColor colorWithRed:61.0 / 255 green:160.0 / 255 blue:115.0 / 255 alpha:0.8];
    [logButton setTitle:@"登录" forState:UIControlStateNormal];
    [logButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    logButton.layer.cornerRadius = 5;
    [self.clearView addSubview:logButton];

    UIButton *forgetButton = [UIButton buttonWithType:UIButtonTypeSystem];
    forgetButton.frame = CGRectMake(7, 510, 80, 40);
    [forgetButton setTitle:@"忘记密码" forState:UIControlStateNormal];
    [forgetButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    forgetButton.titleLabel.font = [UIFont systemFontOfSize:18];
    [forgetButton addTarget:self action:@selector(forgetClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.clearView addSubview:forgetButton];
    
    UIButton *regButton = [UIButton buttonWithType:UIButtonTypeSystem];
    regButton.frame = CGRectMake(120, 540, backGroundImageView.frame.size.width - 240, 40);
    [regButton setTitle:@"现在注册拉勾" forState:UIControlStateNormal];
    [regButton setTitleColor:[UIColor colorWithRed:61.0 / 255 green:160.0 / 255 blue:115.0 / 255 alpha:0.8] forState:UIControlStateNormal];
    regButton.titleLabel.font = [UIFont systemFontOfSize:20];
    regButton.titleLabel.font = [UIFont boldSystemFontOfSize:22];
    [regButton addTarget:self action:@selector(logClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.clearView addSubview:regButton];
    
    UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(10, 610, backGroundImageView.frame.size.width / 2 - 30, 2)];
    lineView1.backgroundColor = [UIColor whiteColor];
    [self.clearView addSubview:lineView1];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(backGroundImageView.frame.size.width / 2 - 4, 593, 40, 30)];
    label.text = @"or";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:20];
    [self.clearView addSubview:label];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(backGroundImageView.frame.size.width / 2 + 30, 610, backGroundImageView.frame.size.width / 2 - 40, 2)];
    lineView2.backgroundColor = [UIColor whiteColor];
    [self.clearView addSubview:lineView2];
    
    UIButton *strollButton = [UIButton buttonWithType:UIButtonTypeSystem];
    strollButton.frame = CGRectMake(backGroundImageView.frame.size.width / 2 - 75, 640, 160, 40);
    [strollButton setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [strollButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    strollButton.titleLabel.font = [UIFont systemFontOfSize:20];
    [self.clearView addSubview:strollButton];
    
    
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField endEditing:YES];
    return YES;
}

- (void)forgetClick:(UIButton *)button {
    CheckViewController *check = [[CheckViewController alloc] init];
    [self presentViewController:check animated:YES completion:nil];
    

}

- (void)logClick:(UIButton *)button {
    LoginViewController *logController = [[LoginViewController alloc] init];
    [self presentViewController:logController animated:YES completion:nil];

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
